﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FishServe.Client.Application.Manifest;
using System.Reflection;

namespace FishServe.Client.Application
{
    internal class ModuleManifestResolver
    {
        private ReleaseManifest _releaseManifest;

        public ModuleManifestResolver(ReleaseManifest releaseManifest)
        {
            _releaseManifest = releaseManifest;
        }

        public ModuleManifest GetModuleManifest(Module module)
        {
            AssemblyName moduleAssemblyName = module.GetType().Assembly.GetName();

            foreach (ModuleManifest moduleManifest in _releaseManifest.ModuleManifests)
            {
                if (moduleManifest.Module.Name == moduleAssemblyName.Name &&
                    moduleManifest.Module.Version == moduleAssemblyName.Version)
                    return moduleManifest;
            }
            return null;
        }
    }
}
